package cn.hwadee.muying.service;

import cn.hwadee.muying.commons.base.BaseService;
import cn.hwadee.muying.commons.page.MyPage;
import cn.hwadee.muying.entity.Organization;
import cn.hwadee.muying.entity.User;
import cn.hwadee.muying.mapper.OrganizationMapper;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Mankind
 * @since 2018-04-20
 */
@Service
public class OrganizationService extends BaseService<OrganizationMapper, Organization> {

    @Autowired
    private OrganizationMapper orgMapper;

    public MyPage<Organization> list(MyPage<Organization> page, User cUser, String keyword) throws Exception{
        List<Organization> organizations = orgMapper.list(page,cUser,keyword);
        page.setRecords(organizations);
        return page;
    }

    public List<Organization> selectAll() {
        return orgMapper.selectList(
                new EntityWrapper<Organization>()
                        .and("valid=1"));
    }

}
